const JInquirer = require('./index');
let options = [
    {
        type:"input",
        message:"请输入你的姓名：",
        name:"name",
        notNull:true
    },{
        type:"input",
        message:"请输入你的年龄:",
        name:"age",
        default:18,
        validate:(val)=>{
            if(val < 0 || val > 150){
                return "请输入0~150之间的数字";
            }
            return true;
        }
    },{
        type:"file",
        message:"请选择文件：",
        name:"fileName",
        default:"",
        dirname:__dirname,
    },{
        type:"folder",
        message:"请选择文件夹：",
        name:"folderName",
        default:"",
        pathType:'absolute',
        dirname:__dirname,
    },{
        type:"list",
        message:"请选择你喜欢的水果：",
        name:"fruit",
        default:"Apple",
        choices:[
            "Apple",
            "pear",
            "Banana"
        ],
    },{
        type:"expand",
        message:"请选择一个颜色：",
        name:"color",
        default:"red",
        choices:[
            {
                key : 'R',
                value : "red"
            },
            {
                key : 'B',
                value : "blue"
            },
            {
                key : 'G',
                value : "green"
            }
        ]
    },{
        type:"checkbox",
        message:"选择一至多种颜色：",
        name:"color2",
        choices:[
            "red",
            "blue",
            "green",
            "pink",
            "orange"
        ]
    },{
        type:"password",
        message:"请输入你的密码：",
        name:"pwd"
    },{
        type:"editor",
        message:"写下你想写的东西：",
        name:"editor"
    }
];
let options1 = [{
        type:"input",
        message:"请输入你的姓名：",
        name:"name",
        notNull:true
    },{
    type: 'expandList',
    name: 'choice',
    message: 'your choice:',
    choices:{
        'aa': [ 'aaa1', 'aaa2', 'aaa3', 'aaa4' ],
        'bb': [ 'bbb1', 'bbb2' ],
        'cc': [ 'ccc1' ]
      }
}];
let options2 = [{
    type: 'checkbox',
    name: 'test',
    message: 'your choice:',
    default:['a','b','ff'],
    notConfirm:true,
    choices:[
        'a','b','c','d'
    ]
}];
let options3 = [{
    type:"file",
    message:"请选择文件：",
    name:"fileName",
    default:"",
    dirname:__dirname,
    pathType:'absolute'
}];
let j = new JInquirer(options3);
let res = j.prompt().then(res=>{
    console.log(res);
});
